<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div>本页面来自http://localhost:4005，将要通过Ajax访问http://localhost:8000，从跨域请求中得到响应</div>
    <button>发送请求</button>

    <script>
        var btn = document.querySelector('button')
        btn.onclick = function () {
            var xhr = new XMLHttpRequest();
            // http://localhost:8000/index.html 访问 http://localhost:4000/getSomething
            xhr.open('PUT', 'http://localhost:8000/getSomething');
            xhr.onreadystatechange = function(){
                if ( xhr.readyState == 4 && xhr.status == 200 ) {
                    console.log(xhr.responseText)
                }
            };
            xhr.send();
        };
    </script>
</body>
</html>